package com.study.shengsiyuan.example06;

import org.junit.Test;

import com.google.protobuf.InvalidProtocolBufferException;

public class ProtobufTest {
	@Test
	public void test1() throws InvalidProtocolBufferException {
		//构建器创建对象 ，方法调用 ：链式调用
		// 构建后的对象不可变。
		DataInfo.Student student =
			DataInfo.Student
			.newBuilder()
			.setName("张三")
			.setAge(27)
			.setAddress("合肥")
			.build();
		byte[] student2byteArray = student.toByteArray();
		//解析字节数组
		DataInfo.Student student2=DataInfo.Student.parseFrom(student2byteArray);
		System.out.println(student2.getName()+";"+student2.getAge()+";"+student2.getAddress());
	}
}
